<h1>Editing media</h1>

<% form_for(@record) do |f| %>
  <%= f.error_messages %>
	  <% @record.get_headers.each do |a| %>
  	<p> <%=view_attr(a,f)%> </p>
	   <% end %>
    <%= f.submit 'Update' %>
<% end %>
<a href="<%="/#{@name}s/#{@record.id}"%>" target="show" class="show_item">Cancel</a>
<script>
$(".show_item").click(function(e){e.preventDefault();$('#show').load(this.href)});

      function submitForm(e, callback){
            var $form = (typeof(e)==='string') ? $(e) : $(e.target);
                alert("enter submit");
            if ($form.length) {
                  alert( $form.attr('action'));
                $.ajax({
                    url: $form.attr('action'),
                    data: $form.serialize(),
                    type: $form.attr('method'),
                    success: function (data, textStatus) {
                        $("#show").html(data);
                    },
                    error: function (data) {
                       $("#show").html(data);
                     }
                });

            }
                   return false;
                }
                $('.edit_<%=@name%>').submit(submitForm);
                //$('.whiteButton').click(submitForm);

</script>
